#! /usr/bin/env python
# encoding: utf-8
# Marcelo Lira, 2007 (setanta)

import os, sys
import Params, intltool

# the following two variables are used by the target "waf dist"
VERSION='0.5.1-waf'
APPNAME='ereseva'

# these variables are mandatory ('/' are converted automatically)
srcdir = '.'
blddir = 'build'

def set_options(opt):
    # add your custom options here, for example:
    #opt.add_option('--bunny', type='string', help='how many bunnies we have', dest='bunny')
    pass

def configure(conf):
    conf.check_tool('python')
    conf.check_python_version((2,5,1))
    #conf.check_tool('intltool')

    conf.check_pkg('pygtk-2.0', destvar='PYGTK', vnum='2.12.0', mandatory=True)
    conf.check_pkg('pygobject-2.0', destvar='PYGOBJECT', vnum='2.12.0', mandatory=True)

    conf.define('VERSION', VERSION)
    conf.define('GETTEXT_PACKAGE', 'ereseva')
    conf.define('PACKAGE', 'ereseva')
    conf.define('PACKAGE_DATADIR', conf.env['DATADIR'] + '/ereseva')
    conf.define('PACKAGE_LOCALEDIR', conf.env['DATADIR'] + '/locale')

def build(bld):
    # process subfolders from here
    bld.add_subdirs('src data po')

    obj = bld.create_obj('py')
    #obj.source = 'ereseva.py'
    obj.find_sources_in_dirs('.')

def shutdown():
    #gnome.postinstall_icons()
    pass

def dist():
    # set the compression type to gzip (default is bz2)
    import Scripting
    Scripting.g_gz = 'gz'

    # after making the package, print the md5sum
    import md5
    from Scripting import DistTarball
    (f, filename) = DistTarball(APPNAME, VERSION)
    f = file(filename,'rb')
    m = md5.md5()
    readBytes = 1024 # read 1024 bytes per time
    while (readBytes):
        readString = f.read(readBytes)
        m.update(readString)
        readBytes = len(readString)
    f.close()
    print filename, m.hexdigest()
    sys.exit(0)

